package com.zws.cucumber.bootstrap.cass;

import com.zws.cucumber.util.cass.ZwsCassContext;

import static com.zws.cucumber.bootstrap.ZwsCassBootstrap.CASSANDRA_PORT;
import static com.zws.cucumber.bootstrap.cass.ZwsBootstrapUtil.elapsed;
import static com.zws.cucumber.bootstrap.cass.ZwsBootstrapUtil.startTimer;

public final class ZwsLocalCassBootstrap implements ZwsCassBootstrap {

    @Override
    public int getCassandraPort() {
        return CASSANDRA_PORT;
    }

    @Override
    public int getBackdoorPort() {
        return -1;
    }

    @Override
    public String getPathOfSystemLogs() {
        throw new UnsupportedOperationException();
    }

    @Override
    public void prepareAndStartCassandra() throws Exception {
        throw new UnsupportedOperationException();
    }

    @Override
    public ZwsCassContext boot(String creationScriptPath, String dataScriptPath, String keyspace) throws Exception {
        try {
            startTimer();
            //System.setProperty("cassandra.storagedir", CASSANDRA_STORAGE_DIR);
            ZwsCassContext cassContext = new ZwsCassContext();
            ZwsBootstrapUtil.printf("boot local cassandra done, elapsed: %d\n", elapsed());
            return cassContext;
        } catch (Throwable t) {
            throw new RuntimeException(t);
        }
    }
}
